Skip to content

gh-122988: Clarify that types.get_original_bases() ignores inherited __orig_bases__ - #156917

Open
owenthcarey wants to merge 1 commit into
python:mainfrom
owenthcarey:gh-122988-get-original-bases-docs
Open

gh-122988: Clarify that types.get_original_bases() ignores inherited __orig_bases__#156917
owenthcarey wants to merge 1 commit into
python:mainfrom
owenthcarey:gh-122988-get-original-bases-docs

Conversation

@owenthcarey

@owenthcarey owenthcarey commented Sep 4, 2026

Copy link
Copy Markdown

The docs for types.get_original_bases() say that for classes that have an __orig_bases__ attribute, the function returns cls.__orig_bases__. That reads as if the function is equivalent to attribute access, but the implementation only looks in cls.__dict__. A class whose base defines __orig_bases__ will inherit the attribute, while get_original_bases() correctly falls back to cls.__bases__ for it.

This rewords the paragraph to say the lookup is on the class's own namespace and that inherited attributes are ignored, and adds a short example of that case to the existing examples block.

Fixes #122988

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34385299 | 📁 Comparing 3f4bda6 against main (7b4364d)

  🔍 Preview build  

1 file changed
± library/types.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

get_original_bases does not return what cls.__orig_bases__ returns

1 participant